﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ext.Net;
using Sio.Mdm.Entities;
using Sio.Mdm.Client;
using Sio.Mdm.BF.Idm;
using Sio.Mdm.BF.Sifranti;
using Sio.Mdm.BF.Administracija;
using Sio.Mdm.Types.Database;
using Sio.Mdm.Types;
using System.Collections.Generic;
using Sio.Mdm.Web.Controls;

namespace Sio.Mdm.Web.Uporabnik
{
    public partial class Content : Controls.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !X.IsAjaxRequest)
            {

                //preberemo IDM številko
                int IdmStevilka = 100;
                if (UserSession != null)
                {
                    IdmStevilka = UserSession.IdmStevilka;
                }

                UporabniskiRacun uporabnik = EntityFactory.LoadEntity<UporabniskiRacun>
               (new Filter<UporabniskiRacun>().Where(r => r.IdmStevilka == IdmStevilka));

                if (uporabnik.EntityState != EntityState.Unknown)
                {
                    ImePriimek.Value = String.Format("{0} {1}", uporabnik.Ime, uporabnik.Priimek);
                    idPodrobnosti100.Title = String.Format("Podrobnosti ", ImePriimek.Value);
                }
            }
        }
        [DirectMethod(ShowMask = true)]
        public void ShraniSpremembe(int IdmStevilka)
        {
            if (IdmStevilka > 0)
            {
                //  var slService = ServiceFactory.GetService<IUceciService>();
                //  EntityCollection<Ucec> uceci = null;
                //  slService.Select(ref uceci, r => r.IdmStevilka == IdmStevilka, this.UserSession);

                //  if (uceci.Count == 1)
                //  {
                //    uceci[0].Naslov = this.tfNaslov.Value.ToString();
                //    uceci[0].Emso = Convert.ToInt64(this.tfEMSO.Value);
                //    uceci[0].DavcnaStevilka = Convert.ToInt32(this.tfDavcna.Value);
                //    uceci[0].PostaId = Convert.ToInt16(this.cbPosta.SelectedItem);
                //    uceci[0].ObcinaId = Convert.ToInt16(this.cbObcine.SelectedItem);

                //    slService.Update(uceci[0], this.UserSession);

                //  }
            }

        }
    }
}
